package com.example.tests;

public class ContactData  implements Comparable<ContactData> {

    private String firstname;
    private String lastname;

    public ContactData() {
    }

    public ContactData(String firstname, String lastname) {
        this.firstname = firstname;
        this.lastname = lastname;
    }

    @Override
    public String toString() {
        return "ContactData [firstname=" + firstname + " lastname=" + lastname + "]";
    }

    @Override
    public int hashCode() {
        //final int prime = 31;
        int result = 1;
        //result = prime * result + ((name == null) ? 0 : name.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ContactData that = (ContactData) o;

        if (firstname != null ? !firstname.equals(that.firstname) : that.firstname != null) return false;
        if (lastname != null ? !lastname.equals(that.lastname) : that.lastname != null) return false;

        return true;
    }

    @Override
    public int compareTo(ContactData other) {
        return this.firstname.toLowerCase().compareTo(other.firstname.toLowerCase());
    }

    public ContactData withFirstname(String firstname) {
        this.firstname = firstname;
        return this;
    }

    public String getFirstname() {
        return firstname;
    }

    public ContactData withLastname(String lastname) {
        this.lastname = lastname;
        return this;
    }

    public String getLastname() {
        return lastname;
    }

}
